﻿// Page1.cpp : implementation file
//

#include "stdafx.h"
#include "TOOLBOX4.h"
#include "Page1.h"
#include "LogAnalyze.h"
#include "WebEngine.h"
#include "Report.h"
#include "MyYUNDUNKeyDlg.h"
#include "WebModule.h"
#include "MD5Checksum.h"
#include "GetIP.h"
#include "ParseWebResultFile.h"
// CPage1

IMPLEMENT_DYNAMIC(CPage1, CWnd)
//CString m_csEventTaskId;
//CWinThread* MyThreadfile;
//int g_mythreadstate=0;
CPage1::CPage1():m_pPath(NULL), m_pPageShare(NULL)
{
	CString modPath = GetModulePath().c_str();
	modPath += _T("\\");

	LoadImg(modPath+_T("res/1.png"), m_imgResultPath);
	m_nRstWidth = m_imgResultPath.GetWidth();
	m_nRstHeight = m_imgResultPath.GetHeight();
	
	if(!LoadImg(modPath+_T("res/fast_off.png"), m_imgFastBtn_off))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	if(!LoadImg(modPath+_T("res/fast_on.png"), m_imgFastBtn_on))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	m_rtFastBtn.left = 220;	//200
	m_rtFastBtn.top = 260;	//220
	m_rtFastBtn.right = m_rtFastBtn.left + m_imgFastBtn_off.GetWidth();
	m_rtFastBtn.bottom = m_rtFastBtn.top + m_imgFastBtn_off.GetHeight();

	if(!LoadImg(modPath+_T("res/all_off.png"), m_imgAllBtn_off))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	if(!LoadImg(modPath+_T("res/all_on.png"), m_imgAllBtn_on))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	m_rtAllBtn.left = 470;	// 550
	m_rtAllBtn.top = 260;	// 220
	m_rtAllBtn.right = m_rtAllBtn.left + m_imgAllBtn_off.GetWidth();
	m_rtAllBtn.bottom = m_rtAllBtn.top + m_imgAllBtn_off.GetHeight();

	if(!LoadImg(modPath+_T("res/cus_off.png"), m_imgCusBtn_off))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	if(!LoadImg(modPath+_T("res/cus_on.png"), m_imgCusBtn_on))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}

	m_rtCusBtn.bottom = m_rtFastBtn.bottom;
	m_rtCusBtn.right = m_rtAllBtn.right;
	m_rtCusBtn.left = m_rtCusBtn.right - m_imgCusBtn_off.GetWidth();
	m_rtCusBtn.top = m_rtCusBtn.bottom - m_imgCusBtn_off.GetHeight();

	if(!LoadImg(modPath+_T("res/result_off.png"), m_imgRstBtn_off))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	if(!LoadImg(modPath+_T("res/result_on.png"), m_imgRstBtn_on))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	m_rtRstBtn.left = 780;	
	m_rtRstBtn.top = 520;	
	m_rtRstBtn.right = m_rtRstBtn.left + m_imgRstBtn_off.GetWidth();
	m_rtRstBtn.bottom = m_rtRstBtn.top + m_imgRstBtn_off.GetHeight();

	if(!LoadImg(modPath+_T("res/wait.png"), m_imgWait))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	m_nWaitWidth = m_imgWait.GetWidth();
	m_nWaitHeight = m_imgWait.GetHeight();
	m_rtWait.left = 300;
	m_rtWait.top = 200;
	m_rtWait.right = m_rtWait.left + m_nWaitWidth;
	m_rtWait.bottom = m_rtWait.top + m_nWaitHeight;
	
	if(!LoadImg(modPath+_T("res/report_off.png"), m_imgReportBtn_off))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	if(!LoadImg(modPath+_T("res/report_on.png"), m_imgReportBtn_on))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	m_rtReportBtn.left = 600;
	m_rtReportBtn.top = 490;
	m_rtReportBtn.right = m_rtReportBtn.left + m_imgReportBtn_off.GetWidth();
	m_rtReportBtn.bottom = m_rtReportBtn.top + m_imgReportBtn_off.GetHeight();

/*
	if(!LoadImg(modPath+_T("res\\convert_off.png"), m_imgConvert_off))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	if(!LoadImg(modPath+_T("res\\convert_on.png"), m_imgConvert_on))
	{
		MessageBox(_T("图片加载失败，请检查图片是否存在！"), _T("图片加载失败"), MB_ICONERROR);
		exit(1);
	}
	m_rtConvertBtn.left = 785;
	m_rtConvertBtn.top = 515;
	m_rtConvertBtn.right = m_rtConvertBtn.left + m_imgConvert_off.GetWidth();
	m_rtConvertBtn.bottom = m_rtConvertBtn.top + m_imgConvert_off.GetHeight();
*/
}

CPage1::~CPage1()
{
	if(m_pPath != NULL)
		delete m_pPath;
	if(m_pPageShare != NULL)
		delete m_pPageShare;
	//if(m_pPage2 != NULL)
	//	delete m_pPage2;
	//if(m_pPage3 != NULL)
	//	delete m_pPage3;
}

//BOOL CPage1::m_bIsShowConvertBtn = FALSE;

BOOL CPage1::m_bIsShowWait = FALSE;

CPoint CPage1::m_LBtnDownPos = NULL;
CPoint CPage1::m_LBtnUpPos = NULL;
//CDC* CPage1::m_pDC = NULL;


CTOOLBOX4View * CPage1::m_pView = NULL;

CPage2 * CPage1::m_pPage2 = NULL;
CPage3 * CPage1::m_pPage3 = NULL;

// 查找需要进行后缀名转换的文件
void FindConvertFile(CString cDir)
{
	CString Dir =cDir; 
	if(Dir.Right(1) != _T("\\"))
		Dir += _T("\\*.*");
	else
		Dir += _T("*.*");
	CFileFind cff;
	BOOL bFileExit = cff.FindFile(Dir);
	while(bFileExit)
	{
		bFileExit = cff.FindNextFile();
		if(cff.GetFileName() == _T(".") || cff.GetFileName() == _T(".."))
			continue;
		if(cff.IsDirectory())
			FindConvertFile(cff.GetFilePath());
		else
			FileName_Change(cff.GetFilePath());
	}
}


// 定时器 线程  <开始采集...> 快速采集
unsigned myTimer1Thread(LPVOID lpvParam)
{
	CPage1 * page1 = (CPage1 *)lpvParam;
	page1->m_TimerID = SetTimer(page1->m_hWnd, TIMER1ID, 1000, NULL);

	return 0;
}

// 定时器 线程 <开始采集...>  全盘采集
unsigned myTimer6Thread(LPVOID lpvParam)
{
	CPage1 * page1 = (CPage1 *)lpvParam;
	page1->m_Timer2ID = SetTimer(page1->m_hWnd, TIMER61ID, 1000, NULL);

	return 0;
}
// void getFileMd5(CString lpfile,sqlite3 *db)
// {
// 	
// 	CFileFind finder;
// 	BOOL bl=finder.FindFile(lpfile);// 当前目录
// 	while(bl)
// 	{
// 		bl=finder.FindNextFile();
// 		if(finder.IsDots())// 当前目录和上级目录
// 		{
// 		}
// 		else if(finder.IsDirectory())// 子目录
// 		{
// 			CString cstemp;
// 			cstemp.Format(_T("%s"),finder.GetFilePath());
// 			cstemp+=_T("\\*.*");
// 			getFileMd5(cstemp,db);
// 		}
// 		else
// 		{
// 			if (myWow64EnableWow64FsRedirection(FALSE))//关闭重定向
// 			{
// 			CString strfilename=finder.GetFilePath();// 文件
// 			OutputDebugString(strfilename);
// 			OutputDebugString(CTOOLBOX4App::ms_strMacAddr);
// 			OutputDebugString(m_csEventTaskId);
// 			WIN32_FIND_DATA* findData = new WIN32_FIND_DATA;
// 			memset(findData,0,sizeof(WIN32_FIND_DATA));
// 			HANDLE hd=FindFirstFile(strfilename,findData);
// 			SYSTEMTIME CreationTime;
// 			FILETIME ftTempCreationTime;
// 			SYSTEMTIME LastAccessTime;
// 			FILETIME ftTempLastAccessTime;
// 			SYSTEMTIME LastWriteTime;
// 			FILETIME ftTempLastWriteTime;
// 			CString strCreationTime;//创建时间
// 			CString strLastAccessTime;//访问时间
// 			CString strLastWriteTime;//修改时间
// 			DWORDLONG FileSize = (findData->nFileSizeHigh * (MAXDWORD+1)) + findData->nFileSizeLow;
// 			CString strFileSize;
// 			strFileSize.Format(_T("%d"),FileSize);
// 			FileTimeToLocalFileTime(&(findData->ftCreationTime),&ftTempCreationTime);
// 			FileTimeToSystemTime(&ftTempCreationTime, &CreationTime);
// 			strCreationTime.Format(TEXT("%04d-%02d-%02d %02d:%02d:%02d"), CreationTime.wYear
// 				, CreationTime.wMonth, CreationTime.wDay, CreationTime.wHour, CreationTime.wMinute
// 				, CreationTime.wSecond);
// 			FileTimeToLocalFileTime(&(findData->ftLastAccessTime),&ftTempLastAccessTime);
// 			FileTimeToSystemTime(&ftTempLastAccessTime, &LastAccessTime);
// 			strLastAccessTime.Format(TEXT("%04d-%02d-%02d %02d:%02d:%02d"), LastAccessTime.wYear
// 				, LastAccessTime.wMonth, LastAccessTime.wDay, LastAccessTime.wHour, LastAccessTime.wMinute
// 				, LastAccessTime.wSecond);
// 			FileTimeToLocalFileTime(&(findData->ftLastWriteTime),&ftTempLastWriteTime);
// 			FileTimeToSystemTime(&ftTempLastWriteTime, &LastWriteTime);
// 			strLastWriteTime.Format(TEXT("%04d-%02d-%02d %02d:%02d:%02d"), LastWriteTime.wYear
// 				, LastWriteTime.wMonth, LastWriteTime.wDay, LastWriteTime.wHour, LastWriteTime.wMinute
// 				, LastWriteTime.wSecond);
// 			CString strMD5=_T("");
// 			
// 				CFile File;
// 				if(File.Open(strfilename, CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary))
// 				{									
// 					strMD5 = CMD5Checksum ::GetMD5(File);
// 					
// 					File.Close();
// 				}
// 			
// 			char *uid=NULL;
// 			int ret=0;
// 			
// 			char sql[1024];
// 			char *errMsg=NULL;
// 			memset(sql, 0, 1024);
// 			uid=UnicodeToUtf8(NewGUID());
// 			
// 			_snprintf(sql, 1023, "insert into sensitive_file(sensitivefile_id, sensitivefile_name,sensitivefile_md5, sensitivefile_size, sensitivefile_creation_time,sensitivefile_access_time,sensitivefile_lastwrite_time,mac_address, event_task_id) values('%s','%s', '%s', '%s', '%s', '%s',  '%s', '%s','%s')", 
// 				uid, UnicodeToUtf8(strfilename),UnicodeToUtf8(strMD5), UnicodeToUtf8(strFileSize), UnicodeToUtf8(strCreationTime), UnicodeToUtf8(strLastAccessTime),UnicodeToUtf8(strLastWriteTime),UnicodeToUtf8(CTOOLBOX4App::ms_strMacAddr), UnicodeToUtf8(m_csEventTaskId));
// 			ret = sqlite3_exec(db, sql, NULL, NULL, &errMsg);
// 			if(ret != SQLITE_OK)
// 			{
// 				OutputDebugString(_T("insert err-sensitive_file"));
// 				OutputDebugString(CString(errMsg));
// 				sqlite3_free(errMsg);
// 			}
// 
// 			if(uid!=NULL)
// 			{
// 				delete []uid;
// 				uid = NULL;
// 			}
// 			
// 			FindClose(hd);
// 			}
// 			myWow64EnableWow64FsRedirection(TRUE);
// 		}
// 	}
// }
// UINT myGetFileList(LPVOID lpvParam)
// {
// 	sqlite3*db;
// 	int ret;
// 	CString dbName = CTOOLBOX4App::ms_strFullResultPath;
// 	CString IniPath1 = CTOOLBOX4App::ms_strResultPath;
// 	
// 	//IniPath += _T("\\采集结果\\OriginalCfg.ini");
// 	IniPath1 += _T("\\采集结果\\OriginalCfg.ydini");
// 	//if(IsFileExist(IniPath1))
// 	GetIniFileKeyValue(IniPath1, _T("MacAndTaskId"), _T("EventTaskId"), m_csEventTaskId);
// 	dbName += _T("主机层\\fileinfo.db");
// 	char * pDbName = UnicodeToUtf8(dbName);
// 	ret = sqlite3_open(pDbName, &db);
// 	if(ret != SQLITE_OK)
// 	{
// 		AfxMessageBox(_T("打开数据库失败-hostlog!"));
// 		OutputDebugString(_T("打开数据库失败!"));
// 		g_mythreadstate=1;
// 		exit(-1);
// 	}
// //	char *cMac = UnicodeToUtf8(CTOOLBOX4App::ms_strMacAddr);
// //	char *cEventid = UnicodeToUtf8(CModule::m_csEventTaskId);
// 	for (vector<CString>::const_iterator itr1 = CTOOLBOX4App::m_SensitivePath.cbegin();itr1 !=  CTOOLBOX4App::m_SensitivePath.cend();itr1++)
// 	{
// 		CString strFilePath = *itr1;
// 		sqlite3_exec(db,"begin;",0,0,0);
// 	
// 		getFileMd5(strFilePath.GetBuffer(),db);
// 		sqlite3_exec(db,"commit;",0,0,0);
// 	}
// 	sqlite3_close(db);
// 	g_mythreadstate=1;
// 	return 0;
// }
BOOL page1CopyDir(CString strSrcPath, CString strDstPath)      //拷贝文件夹及其中的所有内容
{ // 创建目标文件夹
	if (strSrcPath.Right(1) == "\\")
	{
		strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1);
	}
	if (strDstPath.Right(1) == "\\")
	{
		strDstPath = strDstPath.Left(strDstPath.GetLength() - 1);
	}
	CreateDirectory(strDstPath,NULL);
	CFileFind finder;
	// 打开指定的文件夹进行搜索
	BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*"); 
	while(bWorking) 
	{
		// 从当前目录搜索文件
		bWorking = finder.FindNextFile();
		CString strFileName = finder.GetFileName(); 
		CString strSrc = strSrcPath + "\\" + strFileName;
		CString strDst = strDstPath + "\\" + strFileName;
		// 判断搜索到的是不是"."和".."目录

		if(!finder.IsDots())

		{

			// 判断搜索到的目录是否是文件夹

			if(finder.IsDirectory())

			{

				// 如果是文件夹的话，进行递归

				if(!page1CopyDir(strSrc, strDst)) 
				{
					return FALSE;
				}
			}
			else
			{
				// 如果是文件，进行复制
				if(!CopyFile(strSrc, strDst, FALSE))
				{
					if (!PathFileExists(strDst))
					{
						return FALSE;
					}
				}
			} 
		}
	}       
	return TRUE;
}
// 线程函数 快速采集
UINT MyThreadFunc_fast(LPVOID pParam)
{
	CPage1* page1 = (CPage1*)pParam;
	int tackID3 = CHECK_ANALYZE;
	BOOL bIsExit = FALSE;
	do
	{
		CPage1::m_pPage2->m_pPageShare->m_stcContent->SetWindowText(_T("开始采集"));

		page1->m_TimerThread = (HANDLE)_beginthreadex(nullptr, 0, (unsigned(__stdcall*)(void*)) & myTimer1Thread, page1, 0, nullptr);

		CTOOLBOX4App::CopyDbFile();

		CString IniFile = CTOOLBOX4App::ms_strFullResultPath;
		IniFile += _T("OriginalCfg.ydini");
		/////////调用内核工具需要的变量/////////////////
		int nParam = 6;
		CString strSysPathAll;
		CString strSysPath = CTOOLBOX4App::ms_ModPath;
		CString sIsCloudEnv = _T("");
		CString strtemp = _T("");
		CString strutemp = _T("");
		TCHAR szSpeclPath[MAX_PATH] = { 0 };
		SHGetSpecialFolderPath(NULL, szSpeclPath, CSIDL_PROGRAM_FILES, false);
		CString strFilePath(szSpeclPath);
		BOOL bFree = TRUE;
		CString RtPath = CTOOLBOX4App::ms_strFullResultPath + _T("内核层\\采集结果.ydtxt");
		CString mDisk = NULL;
		CString dPath;
		CFileFind m_FileFind;
		TCHAR Drive[MAX_PATH] = { 0 };
		GetSystemDirectory(Drive, MAX_PATH);
		CString fPath(Drive);
		fPath = fPath.Left(1);
		mDisk = fPath;
		////////////////////////
		// 删除xml文件
	/*	CString str;
		if(CTOOLBOX4App::m_bisUDisk)
		{
			str = CTOOLBOX4App::m_strSavePathKey;
		}
		else
		{
			str = CTOOLBOX4App::m_strSavePath;
			str += _T("\\采集工具");
		}
		str += _T("\\采集结果\\");
		str += CTOOLBOX4App::ms_strMacAddr;
		CModule::MyDeleteFile(str);*/

		// 删除所有采集结果,并拷贝空数据库
		CTOOLBOX4App::DelResultFile();

		CDisposeResult::MyClearVector();

		CModule module;
		CLogAnalyze logAnal;
		sqlite3* db;
		int ret;
		CString dbName = CTOOLBOX4App::ms_strFullResultPath;
		dbName += _T("主机层\\hongtan004.db");
		char* pDbName = UnicodeToUtf8(dbName);

		ret = sqlite3_open(pDbName, &db);
		if (ret != SQLITE_OK)
		{
			AfxMessageBox(_T("打开数据库失败-hostlog!"));
			OutputDebugString(_T("打开数据库失败!"));
			exit(-1);
		}

		if (page1->m_TimerID != 0)
			KillTimer(page1->m_hWnd, page1->m_TimerID);
		TerminateThread(page1->m_TimerThread, 0);

		//CPage1::m_pPage2->m_pPageShare->m_stcContent->ShowWindow(SW_HIDE);
		CPage1::m_pPage2->m_pPageShare->m_stcContent->SetWindowText(_T(" "));

		
		CWebModule WebMod;

		// 主机信息
		module.HostBaseInfo(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 网卡
		module.NetWorkCard(CPage1::m_pPage2->m_hWnd, db);

		if (CModule::m_bStop)
			break;
		// 内存镜像
		module.Memory(CPage1::m_pPage2->m_hWnd, db);

		if (CModule::m_bStop)
			break;

		// 系统补丁
		module.PathInfoTrace(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 服务
		module.Service(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 进程
		module.Process(CPage1::m_pPage2->m_hWnd, db);

		if (CModule::m_bStop)
			break;
		// 文件操作痕迹
		module.FileTrace(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 网络连接
		module.Port(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 计划任务
		module.TaskListsInfo(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 启动项
		module.StartUpInfo(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 硬件信息
		module.Hardware(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 联网痕迹
		module.NetTrace(CPage1::m_pPage2->m_hWnd, FASTGATHER, db);
		if (CModule::m_bStop)
			break;
		// USB插拔记录
		module.USBTrace(CPage1::m_pPage2->m_hWnd, FASTGATHER, db);
		if (CModule::m_bStop)
			break;
		// 安装软件
		CDisposeResult::MyClearSoftWare();
		module.SoftWare(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		// 无线通讯设备
		module.Wireless(CPage1::m_pPage2->m_hWnd, db);

		if (CModule::m_bStop)
			break;

		{
			WebMod.WebFile(1);	// Web检测
			WaitForSingleObject(CWebModule::m_shThread, INFINITE); // 永久等待
			CloseHandle(CWebModule::m_shThread);
			CWebModule::m_shThread = NULL;
		}
		int tackID = WEBENGINE_FAST;
		//if(IsWow64())
		{
			WebMod.CustomWeb(page1->m_pPage2->m_hWnd, tackID);
			WaitForSingleObject(CWebModule::m_shThread, INFINITE); // 永久等待
			CloseHandle(CWebModule::m_shThread);
			CWebModule::m_shThread = NULL;
		}

		TASKPROGRESS ofX;
		ofX.pszText = TEXT("Web检测完成");
		ofX.nProgress = 100;
		SendMessage(page1->m_pPage2->m_hWnd, WM_RETPROGRESS, (WPARAM)&tackID, (LPARAM)&ofX);
		if (CModule::m_bStop)
			break;

		// 数据库日志
		module.DataBaseLogInfo(CPage1::m_pPage2->m_hWnd, db, 1, NULL, NULL);
		if (CModule::m_bStop)
			break;
		// 主机日志

		module.HostLog(CPage1::m_pPage2->m_hWnd, FASTGATHER, NULL, db, CTOOLBOX4App::ms_strFullResultPath);

		if (CModule::m_bStop)
			break;
		//USN
		module.USNTrace(mDisk, CPage1::m_pPage2->m_hWnd, db, 1, NULL, NULL, true);
		if (CModule::m_bStop)
			break;
		//磁盘文件
		module.FileInfoTrace(mDisk, CPage1::m_pPage2->m_hWnd, db, 1, NULL, NULL, true);
		if (CModule::m_bStop)
			break;

		// 文件共享
		module.FileShare(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		// 剪切板
		module.Clipboard(CPage1::m_pPage2->m_hWnd, db);

		if (CModule::m_bStop)
			break;
		// 安全基线
		module.AccountSec(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		//// arp  
		module.ARPTrace(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		//DNS

		module.DNSTrace(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 日志策略检测
		module.LogPolicyTrace(CPage1::m_pPage2->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 综合分析
	//if(CModule::m_bStop)
	//	goto STOP;
		
		TASKPROGRESS ofX3;
		ofX3.pszText = TEXT("正在进行结果分析...");
		ofX3.nProgress = 1;
		SendMessage(page1->m_pPage2->m_hWnd, WM_RETPROGRESS, (WPARAM)&tackID3, (LPARAM)&ofX3);
		// 写数据库
		//CPage1::m_pPage2->m_pPageShare->m_stcContent->SetWindowText(_T("正在分析..."));


		CTime t1 = CTime::GetCurrentTime();
		CTime t3 = CTime::GetCurrentTime();

		t3 -= 30 * 24 * 3600;      // 1个月
		module.WriteSqlite3(page1->m_pPage2->m_hWnd, tackID3, 1, t3, t1);
		if (CModule::m_bStop)
			break;
		SetIniFileKeyValue(IniFile.GetBuffer(), TEXT("IsStop"), TEXT("isStop"), _T("F_1"));
		logAnal.SynthesisAnalyze(page1->m_pPage2->m_hWnd, tackID3, FASTGATHER, db);
		sqlite3_close(db);
		///////////////////////////////////////
		if (CModule::m_bStop)
			break;

		SetIniFileKeyValue(IniFile.GetBuffer(), TEXT("IsStop"), TEXT("isStop"), _T("F_0"));
		// 在此处生成HTML文件
	//2020.5.29xjf暂时去掉查看结果的html
	/*AFX_THREADPROC MyFunc1 = MyThreadFunc_BuildHtml;
	CWinThread* MyThread1 = AfxBeginThread(MyFunc1, page1 , THREAD_PRIORITY_NORMAL , 0 , 0 , NULL);
	WaitForSingleObject(MyThread1->m_hThread, INFINITE);*/

	/*	// 报告
		AFX_THREADPROC MyFunc2 = MyThreadFunc_BuildReport;
		CWinThread* MyThread2 = AfxBeginThread(MyFunc2, page1 , THREAD_PRIORITY_NORMAL , 0 , 0 , NULL);
		WaitForSingleObject(MyThread2->m_hThread, INFINITE);*/
		if (CTOOLBOX4App::m_bNetWork)
		{
			//弹框，提问是否压缩结果包
			if (AfxMessageBox(TEXT("是否授权压缩结果包?压缩完成后将自动关闭程序!"), MB_YESNO) == IDYES)
			{
				// 给数据库添加一个标识, 避免重复导入
				CDisposeResult::ImportFlag();

				bIsExit = TRUE;
				if (CTOOLBOX4App::m_strUSavePathKey.GetLength() == 0)
				{
					CDisposeResult::ImportFlag();

					bIsExit = TRUE;
					//将结果路径的采集工具压缩
					CString str_zipPath = Str_SavePath;
					str_zipPath = str_zipPath + +TEXT(".zip");
					DeleteFile(str_zipPath);
					if (ZipFile_7Z(Str_SavePath, str_zipPath))
					{
						char check[8] = "toolbox";
						if (!addcheckfor7Z(str_zipPath, check, sizeof(char) * 8))
							OutputDebugString(_T("快速采集结果压缩包添加校验失败!"));
					}
					if (Str_SavePath.GetLength() != 0)
					{
						myDeleteDirectory(Str_SavePath, TRUE);
					}

				}
				else
				{


					//将结果路径的采集工具压缩
					strtemp = CTOOLBOX4App::m_strSavePathKey;
					CString str_zipPath = strtemp + TEXT(".zip");
					DeleteFile(str_zipPath);
					if (ZipFile_7Z(strtemp, str_zipPath))
					{
						char check[8] = "toolbox";
						if (!addcheckfor7Z(str_zipPath, check, sizeof(char) * 8))
							OutputDebugString(_T("自定义采集结果压缩包添加校验失败!"));
					}
					CreateDirectory(CTOOLBOX4App::m_strUSavePathKey, NULL);

					strtemp = CTOOLBOX4App::m_strSavePathKey;
					strutemp = CTOOLBOX4App::m_strUSavePathKey;
					CString strNewFile;
					strNewFile = strutemp + _T(".zip");
					DeleteFile(strNewFile);
					//	CPage4::page4CopyDir()
					CopyFile(str_zipPath, strNewFile, TRUE);
					//page4CopyDir(str_zipPath, CTOOLBOX4App::m_strUSavePathKey);
					if (strtemp.GetLength() != 0)
					{
						myDeleteDirectory(strtemp, TRUE);
					}

					DeleteFile(str_zipPath);
				}
			}
		}
		else
		{
			OutputDebugString(CTOOLBOX4App::m_strUSavePathKey);
			if (CTOOLBOX4App::m_strUSavePathKey.GetLength() != 0)
			{


				CreateDirectory(CTOOLBOX4App::m_strUSavePathKey, NULL);
				OutputDebugString(CTOOLBOX4App::m_strUSavePathKey);
				strtemp = CTOOLBOX4App::m_strSavePathKey;
				strutemp = CTOOLBOX4App::m_strUSavePathKey;
				//	CPage4::page4CopyDir()

				page1CopyDir(strtemp, strutemp);
				OutputDebugString(strtemp);
				//删除硬盘里的存储结果
				if (strtemp.GetLength() != 0 || CTOOLBOX4App::m_strSavePathKey.GetLength() > 1)
				{
					myDeleteDirectory(strtemp, TRUE);
				}

				dPath = CTOOLBOX4App::ms_strResultPath + _T("\\WebEngine");

				if (m_FileFind.FindFile(dPath))
				{
					myDeleteDirectory(dPath, TRUE);

				}
			}
		}
		/*	CreateDirectory(CTOOLBOX4App::m_strUSavePathKey,NULL);

	strtemp=CTOOLBOX4App::m_strSavePathKey+_T("\\采集结果");
	strutemp=CTOOLBOX4App::m_strUSavePathKey+_T("\\采集结果");

	page1CopyDir(strtemp, strutemp);
	myDeleteDirectory(strtemp,TRUE);
	dPath = CTOOLBOX4App::ms_strResultPath + _T("\\WebEngine");

	if(m_FileFind.FindFile(dPath))
	{
		myDeleteDirectory(dPath,TRUE);

	}

	//CopyDir（CTOOLBOX4App::m_strSavePathKey,CTOOLBOX4App::m_strUSavePathKey);
	sqlite3_close(db);
	if(CTOOLBOX4App::m_bNetWork)
	{
		//弹框，提问是否压缩结果包
		if(AfxMessageBox(TEXT("是否授权压缩结果包?压缩完成后将自动关闭程序!"),MB_YESNO) == IDYES)
		{
			// 给数据库添加一个标识, 避免重复导入
			CDisposeResult::ImportFlag();

			bIsExit = TRUE;
			//将结果路径的采集工具压缩
			CString str_zipPath = Str_SavePath + TEXT(".zip");
			DeleteFile(str_zipPath);
			if(ZipFile_7Z(Str_SavePath,str_zipPath))
			{
				char check[8] = "toolbox";
				if(!addcheckfor7Z(str_zipPath, check, sizeof(char)*8))
					OutputDebugString(_T("快速采集结果压缩包添加校验失败!"));
			}
			myDeleteDirectory(CTOOLBOX4App::ms_strResultPath, TRUE);
		}
	}*/
	} while (false);
	
	TASKPROGRESS ofX4;
	ofX4.pszText = TEXT("采集完成");
	ofX4.nProgress = 100;
	SendMessage(page1->m_pPage2->m_hWnd, WM_RETPROGRESS, (WPARAM)&tackID3, (LPARAM)&ofX4);

	CPage1::m_pPage2->m_pPageShare->m_stcContent->SetWindowText(_T("采集完成"));
	CPage1::m_pPage2->m_pPageShare->m_stcContent->ShowWindow(SW_SHOW);
	CPage2::m_bIsRet = TRUE;  // 采集完成,显示返回按钮
	CPage1::m_pPage2->Invalidate();

	if(bIsExit)
		exit(0);

	return 0;
}

// 线程函数 全盘采集
UINT MyThreadFunc_all(LPVOID pParam)
{
	CPage1 * page1 = (CPage1 *)pParam;
	BOOL bIsExit = FALSE;
	CString IniFile = CTOOLBOX4App::ms_strFullResultPath;
	int tackID3 = CHECK_ANALYZE;
	do
	{
		CPage1::m_pPage3->m_pShare->m_stcContent->SetWindowText(_T("开始采集"));
		CPage1::m_pPage3->m_pShare->m_stcContent->ShowWindow(SW_SHOW);

		CTOOLBOX4App::CopyDbFile();

		
		IniFile += _T("OriginalCfg.ydini");

		page1->m_Timer2Thread = (HANDLE)_beginthreadex(nullptr, 0, (unsigned(__stdcall*)(void*)) & myTimer6Thread, page1, 0, nullptr);
		// 删除xml文件
	/*	CString str;
		if(CTOOLBOX4App::m_bisUDisk)
		{
			str = CTOOLBOX4App::m_strSavePathKey;
		}
		else
		{
			str = CTOOLBOX4App::m_strSavePath;
			str += _T("\\采集工具");
		}
		str += _T("\\采集结果\\");
		str += CTOOLBOX4App::ms_strMacAddr;
		CModule::MyDeleteFile(str);*/

		// 删除所有采集结果,并拷贝空数据库
		CTOOLBOX4App::DelResultFile();

		CDisposeResult::MyClearVector();
		/*
		// 清空 联网痕迹-深度 采集结果
		CLogAnalyze::ClearNetDeepRst();
		// 清空 介质痕迹-深度 采集结果
		CLogAnalyze::ClearUsbDeepRst();

		*/
		CModule module;
		CString dPath;
		
		CFileFind m_FileFind;
		sqlite3* db;
		int ret;
		CString dbName = CTOOLBOX4App::ms_strFullResultPath;
		dbName += _T("主机层\\hongtan004.db");
		char* pDbName = UnicodeToUtf8(dbName);

		ret = sqlite3_open(pDbName, &db);
		if (ret != SQLITE_OK)
		{
			AfxMessageBox(_T("打开数据库失败-hostlog!"));
			OutputDebugString(_T("打开数据库失败!"));
			exit(-1);
		}
		CString mDisk = NULL;


		mDisk = CPage4::m_strDisk;
		/////////调用内核工具需要的变量/////////////////
		int nParam = 6;
		CString strSysPath = CTOOLBOX4App::ms_ModPath;
		CString sIsCloudEnv = _T("");
		CString strtemp = _T("");
		CString strutemp = _T("");
		TCHAR szSpeclPath[MAX_PATH] = { 0 };
		SHGetSpecialFolderPath(NULL, szSpeclPath, CSIDL_PROGRAM_FILES, false);
		CString strFilePath(szSpeclPath);
		BOOL bFree = TRUE;
		CString RtPath = CTOOLBOX4App::ms_strFullResultPath + _T("内核层\\采集结果.ydtxt");
		////////////////////////

		if (page1->m_Timer2ID != 0)
			KillTimer(page1->m_hWnd, page1->m_Timer2ID);
		TerminateThread(page1->m_Timer2Thread, 0);

		CPage1::m_pPage3->m_pShare->m_stcContent->SetWindowText(_T(" "));
		CPage1::m_pPage3->m_pShare->m_stcCurent->ShowWindow(SW_HIDE);

		//if(CModule::m_bStop)
		//	goto STOP;

		CWebModule WebMod;
		CLogAnalyze LogAnal;
		// 主机信息
		module.HostBaseInfo(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		// 网卡
		module.NetWorkCard(CPage1::m_pPage3->m_hWnd, db);

		if (CModule::m_bStop)
			break;

		// 内存镜像
		module.Memory(CPage1::m_pPage3->m_hWnd, db);

		if (CModule::m_bStop)
			break;
		// 系统补丁
		module.PathInfoTrace(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		// 服务
		module.Service(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;


		//进程

		module.Process(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		module.FileTrace(CPage1::m_pPage3->m_hWnd, db);//文件操作痕迹
		if (CModule::m_bStop)
			break;
		// 网络连接
		module.Port(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 计划任务
		module.TaskListsInfo(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;


		// 启动项
		module.StartUpInfo(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		// 硬件信息
		module.Hardware(CPage1::m_pPage3->m_hWnd, db);

		if (CModule::m_bStop)
			break;
		// 联网痕迹
		module.NetTrace(CPage1::m_pPage3->m_hWnd, ALLDISKGATHER, db);
		if (CModule::m_bStop)
			break;


		// USB插拔记录
		module.USBTrace(CPage1::m_pPage3->m_hWnd, ALLDISKGATHER, db);
		if (CModule::m_bStop)
			break;

		// 安装软件
		CDisposeResult::MyClearSoftWare();
		module.SoftWare(CPage1::m_pPage3->m_hWnd, db);
		//CDisposeResult::WriteXml();
		if (CModule::m_bStop)
			break;

		// 无线通讯设备
		module.Wireless(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		int tackID = WEBENGINE_ALL;
		WebMod.WebFile(2);	// Web检测
		WaitForSingleObject(CWebModule::m_shThread, INFINITE); // 永久等待
		CloseHandle(CWebModule::m_shThread);
		CWebModule::m_shThread = NULL;
		WebMod.CustomWeb(page1->m_pPage3->m_hWnd, tackID);
		WaitForSingleObject(CWebModule::m_shThread, INFINITE); // 永久等待
		CloseHandle(CWebModule::m_shThread);
		CWebModule::m_shThread = NULL;


		TASKPROGRESS ofX;
		ofX.pszText = TEXT("Web文件采集完成");
		ofX.nProgress = 100;
		SendMessage(page1->m_pPage3->m_hWnd, WM_RETPROGRESS, (WPARAM)&tackID, (LPARAM)&ofX);
		if (CModule::m_bStop)
			break;

		//数据库日志
		module.DataBaseLogInfo(CPage1::m_pPage3->m_hWnd, db, 2, NULL, NULL);
		if (CModule::m_bStop)
			break;
		// 主机日志
		//module.HostLog(CPage1::m_pPage2->m_hWnd, FASTGATHER, NULL, db);
		module.HostLog(CPage1::m_pPage3->m_hWnd, FASTGATHER, NULL, db, CTOOLBOX4App::ms_strFullResultPath);

		if (CModule::m_bStop)
			break;
		//usn
		module.USNTrace(mDisk, CPage1::m_pPage3->m_hWnd, db, 2, NULL, NULL, false);
		if (CModule::m_bStop)
			break;

		//磁盘文件
		module.FileInfoTrace(mDisk, CPage1::m_pPage3->m_hWnd, db, 2, NULL, NULL, false);
		if (CModule::m_bStop)
			break;

		// 文件共享
		module.FileShare(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		// 剪切板
		module.Clipboard(CPage1::m_pPage3->m_hWnd, db);

		if (CModule::m_bStop)
			break;

		// 安全基线
		module.AccountSec(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		//// arp  
		module.ARPTrace(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		//DNS

		module.DNSTrace(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;

		// 日志策略检测
		module.LogPolicyTrace(CPage1::m_pPage3->m_hWnd, db);
		if (CModule::m_bStop)
			break;
		// 综合分析
		
		TASKPROGRESS ofX3;
		ofX3.pszText = TEXT("正在进行结果分析,请稍候...");
		ofX3.nProgress = 1;
		SendMessage(page1->m_pPage3->m_hWnd, WM_RETPROGRESS, (WPARAM)&tackID3, (LPARAM)&ofX3);



		module.WriteSqlite3(page1->m_pPage3->m_hWnd, tackID3, 2, NULL, NULL);
		if (CModule::m_bStop)
			break;
		SetIniFileKeyValue(IniFile.GetBuffer(), TEXT("IsStop"), TEXT("isStop"), _T("A_1"));
		LogAnal.SynthesisAnalyze(page1->m_pPage3->m_hWnd, tackID3, ALLDISKGATHER, db);
		sqlite3_close(db);
		if (CModule::m_bStop)
			break;
		if (CTOOLBOX4App::m_bNetWork)
		{
			//弹框，提问是否压缩结果包
			if (AfxMessageBox(TEXT("是否授权压缩结果包?压缩完成后将自动关闭程序!"), MB_YESNO) == IDYES)
			{
				// 给数据库添加一个标识, 避免重复导入
				CDisposeResult::ImportFlag();

				bIsExit = TRUE;
				if (CTOOLBOX4App::m_strUSavePathKey.GetLength() == 0)
				{
					CDisposeResult::ImportFlag();

					bIsExit = TRUE;
					//将结果路径的采集工具压缩
					CString str_zipPath = Str_SavePath;
					str_zipPath = str_zipPath + +TEXT(".zip");
					DeleteFile(str_zipPath);
					if (ZipFile_7Z(Str_SavePath, str_zipPath))
					{
						char check[8] = "toolbox";
						if (!addcheckfor7Z(str_zipPath, check, sizeof(char) * 8))
							OutputDebugString(_T("快速采集结果压缩包添加校验失败!"));
					}
					if (Str_SavePath.GetLength() != 0)
					{
						myDeleteDirectory(Str_SavePath, TRUE);
					}

				}
				else
				{
					//将结果路径的采集工具压缩
					strtemp = CTOOLBOX4App::m_strSavePathKey;
					CString str_zipPath = strtemp + TEXT(".zip");
					DeleteFile(str_zipPath);
					if (ZipFile_7Z(strtemp, str_zipPath))
					{
						char check[8] = "toolbox";
						if (!addcheckfor7Z(str_zipPath, check, sizeof(char) * 8))
							OutputDebugString(_T("自定义采集结果压缩包添加校验失败!"));
					}
					CreateDirectory(CTOOLBOX4App::m_strUSavePathKey, NULL);

					strtemp = CTOOLBOX4App::m_strSavePathKey;
					strutemp = CTOOLBOX4App::m_strUSavePathKey;
					CString strNewFile;
					strNewFile = strutemp + _T(".zip");
					DeleteFile(strNewFile);
					//	CPage4::page4CopyDir()
					CopyFile(str_zipPath, strNewFile, TRUE);
					//page4CopyDir(str_zipPath, CTOOLBOX4App::m_strUSavePathKey);
					if (strtemp.GetLength() != 0)
					{
						myDeleteDirectory(strtemp, TRUE);
					}

					DeleteFile(str_zipPath);
				}
			}
		}
		else
		{
			OutputDebugString(CTOOLBOX4App::m_strUSavePathKey);
			if (CTOOLBOX4App::m_strUSavePathKey.GetLength() != 0)
			{


				CreateDirectory(CTOOLBOX4App::m_strUSavePathKey, NULL);
				OutputDebugString(CTOOLBOX4App::m_strUSavePathKey);
				strtemp = CTOOLBOX4App::m_strSavePathKey;
				strutemp = CTOOLBOX4App::m_strUSavePathKey;
				//	CPage4::page4CopyDir()

				page1CopyDir(strtemp, strutemp);
				OutputDebugString(strtemp);
				//删除硬盘里的存储结果
				if (strtemp.GetLength() != 0 || CTOOLBOX4App::m_strSavePathKey.GetLength() > 1)
				{
					myDeleteDirectory(strtemp, TRUE);
				}

				dPath = CTOOLBOX4App::ms_strResultPath + _T("\\WebEngine");

				if (m_FileFind.FindFile(dPath))
				{
					myDeleteDirectory(dPath, TRUE);

				}
			}
		}
	} while (false);
	TASKPROGRESS ofX4;
	ofX4.pszText = TEXT("完成");
	ofX4.nProgress = 100;
	SendMessage(page1->m_pPage3->m_hWnd, WM_RETPROGRESS, (WPARAM)&tackID3, (LPARAM)&ofX4);
	//if(g_mythreadstate==1)
	{
		CPage1::m_pPage3->m_pShare->m_stcContent->SetWindowText(_T("采集完成"));
		CPage1::m_pPage3->m_pShare->m_stcContent->ShowWindow(SW_SHOW);
		CPage3::m_bIsRet = TRUE;  // 采集完成,显示返回按钮
		CPage1::m_pPage3->Invalidate();
	}
	if(bIsExit)
		exit(0);

	//AfxMessageBox(_T("全盘采集 完成"));

	SetIniFileKeyValue(IniFile.GetBuffer(), TEXT("IsStop"), TEXT("isStop"), _T("A_0"));
	return 0;
}

// 线程函数 生成html文件
UINT MyThreadFunc_BuildHtml(LPVOID pParam)
{
	//Sleep(5000);
	CPage1 * pPage1 = (CPage1*)pParam;
/*
	if(CDisposeResult::m_vCaption.empty())
		pPage1->m_pResult->MyReadHtml();
	pPage1->m_pResult->MyTransResult();
	pPage1->m_pResult->BuildHtml();
	
	if(CDisposeResult::m_vLogCaption1.empty())
		pPage1->m_pResult->MyReadLogHtml();
	pPage1->m_pResult->BuildLogHtml();
*/
	if(CDisposeResult::m_vCaption.empty())
		pPage1->m_pResult->MyReadHtml();
	if(CDisposeResult::m_vLogCaption1.empty())
		pPage1->m_pResult->MyReadLogHtml();
	pPage1->m_pResult->BuildHtml();
	pPage1->m_pResult->BuildLogHtml();

	return 0;
}

UINT MyThreadFunc_BuildReport(LPVOID pParam)
{
	CPage1 * pPage1 = (CPage1*)pParam;

	CReport rpt;
	rpt.BuildReport();

	return 0;
}

//// 修改后缀名
//UINT MyThreadFunc_DataConvert(LPVOID pParam)
//{
//	CString ResultDir = CTOOLBOX4App::ms_strResultPath;
//	ResultDir += _T("\\采集结果");
//	FindConvertFile(ResultDir);
//	MessageBox(NULL, _T("转化完成"), _T("提示:"), MB_ICONINFORMATION);
//	return 0;
//}

// 结果保存路径 背景图
void CPage1::ShowPath(HDC hDC)
{
	// 这里使用固定长度，因为图片宽度大于窗口宽度
	m_imgResultPath.Draw(hDC, 9, 120, 880, 25, 0,0,m_nRstWidth, m_nRstHeight);
}


// 快速采集按钮
void CPage1::ShowFastBtn(BOOL flag, HDC hDC)
{
	if(flag)
	{
		m_imgFastBtn_on.Draw(hDC, m_rtFastBtn);
	}
	else
	{
		m_imgFastBtn_off.Draw(hDC, m_rtFastBtn);
	}

}

// 全盘采集按钮
void CPage1::ShowAllBtn(BOOL flag, HDC hDC)
{
	if(flag)
	{
		m_imgAllBtn_on.Draw(hDC, m_rtAllBtn);
	}
	else
	{
		m_imgAllBtn_off.Draw(hDC, m_rtAllBtn);
	}
}

// 自定义采集按钮
void CPage1::ShowCusBtn(BOOL flag, HDC hDC)
{
	if(flag)
	{
		m_imgCusBtn_on.Draw(hDC, m_rtCusBtn);
	}
	else
	{
		m_imgCusBtn_off.Draw(hDC, m_rtCusBtn);
	}
}

// 查看结果按钮
void CPage1::ShowRstBtn(BOOL flag, HDC hDC)
{
	if(flag)
	{
		m_imgRstBtn_on.Draw(hDC, m_rtRstBtn);
	}
	else
	{
		m_imgRstBtn_off.Draw(hDC, m_rtRstBtn);
	}
}

// 查看 分析报告 按钮
void CPage1::ShowReportBtn(BOOL flag, HDC hDc)
{
	if(flag)
	{
		m_imgReportBtn_on.Draw(hDc, m_rtReportBtn);
	}
	else
	{
		m_imgReportBtn_off.Draw(hDc, m_rtReportBtn);
	}
}

// 数据转换按钮
//void CPage1::ShowConvertBtn(BOOL flag, HDC hDc)
//{
//	if(flag)
//	{
//		m_imgConvert_on.Draw(hDc, m_rtConvertBtn);
//	}
//	else
//	{
//		m_imgConvert_off.Draw(hDc, m_rtConvertBtn);
//	}
//}

void GetLocalDisk()
{
	/////////////////  // 获取系统盘符
	TCHAR Drive[MAX_PATH] = {0};
	int i = 0;
	GetLogicalDriveStrings(MAX_PATH,Drive);
	while (Drive[i-1] != '\0' || Drive[i] != '\0')
	{
		i++;
		if(Drive[i] == '\\')
		{
			CPage4::m_strDisk += Drive[i-2];
			CPage4::m_strDisk += Drive[i-1];
			CPage4::m_strDisk += ';';
		}
	}
	////////////////
}

BEGIN_MESSAGE_MAP(CPage1, CWnd)
	ON_WM_CREATE()
	ON_WM_PAINT()
	ON_WM_CTLCOLOR()
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_TIMER()
END_MESSAGE_MAP()



// CPage1 message handlers


int CPage1::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here
	m_font.CreatePointFont(110, L"微软雅黑");
	m_font1.CreatePointFont(200, L"微软雅黑");
	m_pPath = new CStatic;
	m_pPath->Create(_T("  结果保存路径："), WS_CHILD|WS_VISIBLE, CRect(9, 125, 124, 143), this, IDSTATICPATH);
	m_pPath->SetFont(&m_font);

	// 获取系统桌面路径
	//TCHAR MyDir[_MAX_PATH];  
	//SHGetSpecialFolderPath(this->GetSafeHwnd(),MyDir,CSIDL_DESKTOP,0);
	m_pPath2 = new CStatic;
	m_pPath2->Create(/*MyDir*/NULL, WS_CHILD|WS_VISIBLE, CRect(135, 125, 944, 143), this, IDSTATICPATH2);
	m_pPath2->SetFont(&m_font);
	CString savePath(CTOOLBOX4App::m_strSavePath);
//	savePath += _T("\\采集工具");

	CString savePath2(CTOOLBOX4App::m_strSavePath);
	CString strtext(CTOOLBOX4App::m_strUSavePathKey);
	if(CTOOLBOX4App::m_bisUDisk)
	{
		m_pPath2->SetWindowText(strtext);
		CWebEngine::m_StrPath = savePath2;
		CWebEngine::m_StrPath += _T("\\采集结果\\");    
		CWebEngine::m_StrPath += CDisposeResult::m_strMacAddr;
		CWebEngine::m_StrPath += _T("\\WebAttackAction");
	}
	else
	{
		m_pPath2->SetWindowText(savePath);
		CWebEngine::m_StrPath = savePath;
		CWebEngine::m_StrPath += _T("\\采集工具\\采集结果\\");    
		CWebEngine::m_StrPath += CDisposeResult::m_strMacAddr;
		CWebEngine::m_StrPath += _T("\\WebAttackAction");
	}
	

	m_pPageShare = new CPageShare(this);
	m_pPageShare->Create(NULL, TEXT(""), WS_CHILD, CRect(0 ,0, 925, 690), this, CPAGESHARE2);

	m_pResult = new CDisposeResult;

	m_Ver = new CStatic;
	m_Ver->Create(NULL, WS_CHILD|WS_VISIBLE, CRect(570, 20, 680, 60), this, APPVERSION);
	m_Ver->SetFont(&m_font1);
	m_Ver->SetWindowText(CTOOLBOX4App::ms_strInfo);
	// 静态文本空间-显示程序版本 // 23 590 223,  598
	m_Version = new CStatic;
	m_Version->Create(NULL, WS_CHILD|WS_VISIBLE, CRect(23, 665, 273, 690), this, APPVERSION);
	m_Version->SetFont(&m_font);
	m_Version->SetWindowText(CTOOLBOX4App::ms_strVersionInfo);

	

	return 0;
}


void CPage1::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: Add your message handler code here
	// Do not call CWnd::OnPaint() for painting messages
	HDC hDC = dc.GetSafeHdc();
	m_pPageShare->ShowBackGround(hDC);
	m_pPageShare->ShowLogo(hDC);
	
	ShowPath(hDC);

	CPoint mousePos;
	CRect rt_fast(m_rtFastBtn);
	CRect rt_all(m_rtAllBtn);
	CRect rt_cus(m_rtCusBtn);
	CRect rt_rst(m_rtRstBtn);
	CRect rt_close(m_pPageShare->m_rtCloseBtn);
	CRect rt_min(m_pPageShare->m_rtMinBtn);
	CRect rt_report(m_rtReportBtn);
	//CRect rt_Convert(m_rtConvertBtn);
	GetCursorPos(&mousePos);
	ClientToScreen(rt_fast);
	ClientToScreen(rt_all);
	ClientToScreen(rt_cus);
	ClientToScreen(rt_rst);
	ClientToScreen(rt_close);
	ClientToScreen(rt_min);
	ClientToScreen(rt_report);
	//ClientToScreen(rt_Convert);
	if(rt_fast.PtInRect(mousePos))
		ShowFastBtn(TRUE, hDC);
	else
		ShowFastBtn(FALSE, hDC);
	if(rt_all.PtInRect(mousePos))
		ShowAllBtn(TRUE, hDC);
	else
		ShowAllBtn(FALSE, hDC);
	if(rt_cus.PtInRect(mousePos))
		ShowCusBtn(TRUE, hDC);
	else
		ShowCusBtn(FALSE, hDC);
	/*if(rt_rst.PtInRect(mousePos))
		ShowRstBtn(TRUE, hDC);
	else
		ShowRstBtn(FALSE, hDC);*/
	if(rt_close.PtInRect(mousePos))
		m_pPageShare->ShowCloseBtn(TRUE,hDC);
	else
		m_pPageShare->ShowCloseBtn(FALSE,hDC);
	if(rt_min.PtInRect(mousePos))
		m_pPageShare->ShowMinBtn(TRUE, hDC);
	else
		m_pPageShare->ShowMinBtn(FALSE, hDC);
//2020.5.29 去掉分析报告按钮
/*	if(rt_report.PtInRect(mousePos))
		ShowReportBtn(TRUE, hDC);
	else
		ShowReportBtn(FALSE, hDC);
*/
	//m_pPageShare->m_stcCompany->ShowWindow(SW_SHOW);

	if(m_bIsShowWait)
		m_imgWait.Draw(hDC, m_rtWait);

	//// 需要此功能 + 采集过数据 才显示按钮
	//if(CTOOLBOX4App::m_bIsLuJun && m_bIsShowConvertBtn)
	//{
	//	if(rt_Convert.PtInRect(mousePos))
	//		ShowConvertBtn(TRUE, hDC);
	//	else
	//		ShowConvertBtn(FALSE, hDC);
	//}
	
}

// 控件背景透明， 更改字体颜色
HBRUSH CPage1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);

	// TODO:  Change any attributes of the DC here
	switch(nCtlColor)
	{
	case CTLCOLOR_STATIC:
		{
			pDC->SetBkMode(TRANSPARENT);
			pDC->SetTextColor(RGB(255,255,255));
			return   (HBRUSH)::GetStockObject(NULL_BRUSH); 
		}
	default:
		return CWnd::OnCtlColor(pDC,   pWnd,   nCtlColor);
	}
	// TODO:  Return a different brush if the default is not desired
	//return hbr;
}

// 状态切换flag
static BOOL flag1 = TRUE;
static BOOL flag2 = FALSE;
static BOOL flag3 = TRUE;
static BOOL flag4 = FALSE;
static BOOL flag5 = TRUE;
static BOOL flag6 = FALSE;
static BOOL flag7 = TRUE;
static BOOL flag8 = FALSE;
static BOOL flag9 = TRUE;
static BOOL flag10 = FALSE;
static BOOL flag11 = TRUE;
static BOOL flag12 = FALSE;
static BOOL flag13 = TRUE;
static BOOL flag14 = FALSE;
//static BOOL flag15 = TRUE;
//static BOOL flag16 = FALSE;
void CPage1::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	CPoint pt;
	GetCursorPos(&pt);
	CRect rt_fast(m_rtFastBtn);
	CRect rt_all(m_rtAllBtn);
	CRect rt_cus(m_rtCusBtn);
	CRect rt_rst(m_rtRstBtn);
	CRect rt_close(m_pPageShare->m_rtCloseBtn);
	CRect rt_min(m_pPageShare->m_rtMinBtn);
	CRect rt_report(m_rtReportBtn);
	//CRect rt_convert(m_rtConvertBtn);
	ClientToScreen(rt_fast);
	ClientToScreen(rt_all);
	ClientToScreen(rt_cus);
	ClientToScreen(rt_rst);
	ClientToScreen(rt_close);
	ClientToScreen(rt_min);
	ClientToScreen(rt_report);
	//ClientToScreen(rt_convert);
	if(rt_fast.PtInRect(pt))
	{
		//SetClassLong(this->m_hWnd, )
		//HCURSOR hcur;
		//LoadCursor(NULL,)
		//SetCursor()
		if(!flag2)
		{
			InvalidateRect(m_rtFastBtn);
			//CString str;
			//str.Format(_T("%d,%d,%d,%d"),m_rtFastBtn.left,m_rtFastBtn.top,m_rtFastBtn.right, m_rtFastBtn.bottom );
			//AfxMessageBox(str);
			flag2 = TRUE;
			flag1 = FALSE;
		}
	}
	else
	{
		if(!flag1)
		{
			InvalidateRect(m_rtFastBtn);
			flag1 = TRUE;
			flag2 = FALSE;
		}
	}
	if(rt_all.PtInRect(pt))
	{
		if(!flag4)
		{
			InvalidateRect(m_rtAllBtn);
			flag4 = TRUE;
			flag3 = FALSE;
		}
	}
	else
	{
		if(!flag3)
		{
			InvalidateRect(m_rtAllBtn);
			flag3 = TRUE;
			flag4= FALSE;
		}
	}
	if(rt_cus.PtInRect(pt))
	{
		if(!flag6)
		{
			InvalidateRect(m_rtCusBtn);
			flag6 = TRUE;
			flag5 = FALSE;
		}
	}
	else
	{
		if(!flag5)
		{
			InvalidateRect(m_rtCusBtn);
			flag5 = TRUE;
			flag6 = FALSE;
		}
	}
	if(rt_rst.PtInRect(pt))
	{
		if(!flag8)
		{
			InvalidateRect(m_rtRstBtn);
			flag8 = TRUE;
			flag7 = FALSE;
		}
	}
	else
	{
		if(!flag7)
		{
			InvalidateRect(m_rtRstBtn);
			flag7 = TRUE;
			flag8 = FALSE;
		}
	}

	if(rt_close.PtInRect(pt))
	{
		if(!flag10)
		{
			InvalidateRect(m_pPageShare->m_rtCloseBtn);
			flag10 = TRUE;
			flag9 = FALSE;
		}
	}
	else
	{
		if(!flag9)
		{
			InvalidateRect(m_pPageShare->m_rtCloseBtn);
			flag9 = TRUE;
			flag10= FALSE;
		}
	}

	if(rt_min.PtInRect(pt))
	{
		if(!flag12)
		{
			InvalidateRect(m_pPageShare->m_rtMinBtn);
			flag12 = TRUE;
			flag11 = FALSE;
		}
	}
	else
	{
		if(!flag11)
		{
			InvalidateRect(m_pPageShare->m_rtMinBtn);
			flag11 = TRUE;
			flag12= FALSE;
		}
	}

	if(rt_report.PtInRect(pt))
	{
		if(!flag14)
		{
			InvalidateRect(m_rtReportBtn);
			flag14 = TRUE;
			flag13 = FALSE;
		}
	}
	else
	{
		if(!flag13)
		{
			InvalidateRect(m_rtReportBtn);
			flag13 = TRUE;
			flag14= FALSE;
		}
	}

	//if(rt_convert.PtInRect(pt))
	//{
	//	if(!flag16)
	//	{
	//		InvalidateRect(m_rtConvertBtn);
	//		flag16 = TRUE;
	//		flag15 = FALSE;
	//	}
	//}
	//else
	//{
	//	if(!flag15)
	//	{
	//		InvalidateRect(m_rtConvertBtn);
	//		flag15 = TRUE;
	//		flag16= FALSE;
	//	}
	//}

	CWnd::OnMouseMove(nFlags, point);
}

void CPage1::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	GetCursorPos(&m_LBtnDownPos);
	/*CString str;*/
	//str.Format(_T("x=%d,y=%d"), m_LBtnDownPos.x,m_LBtnDownPos.y);
	/*AfxMessageBox(str);*/

	CRect rect(0,0,1000,80);
	CRect rt_close(m_pPageShare->m_rtCloseBtn);
	CRect rt_min(m_pPageShare->m_rtMinBtn);
	ClientToScreen(rect);
	ClientToScreen(rt_close);
	ClientToScreen(rt_min);
	 
	if(rect.PtInRect(m_LBtnDownPos) && !rt_close.PtInRect(m_LBtnDownPos) && !rt_min.PtInRect(m_LBtnDownPos))
	{
		//使鼠标可以拖动窗口
		m_pView->GetParent()->SendMessage(WM_SYSCOMMAND,SC_MOVE|HTCAPTION,0);
	}
	CWnd::OnLButtonDown(nFlags, point);
}

void CPage1::OnLButtonUp(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	do
	{
		// 当等待页面出现后, 屏蔽鼠标点击事件
		if (m_bIsShowWait)
			break;
		GetCursorPos(&m_LBtnUpPos);

		CRect rt_fast(m_rtFastBtn);
		CRect rt_all(m_rtAllBtn);
		CRect rt_cus(m_rtCusBtn);
		CRect rt_rst(m_rtRstBtn);
		CRect rt_close(m_pPageShare->m_rtCloseBtn);
		CRect rt_min(m_pPageShare->m_rtMinBtn);
		CRect rt_report(m_rtReportBtn);
		//CRect rt_convert(m_rtConvertBtn);

		ClientToScreen(rt_fast);
		ClientToScreen(rt_all);
		ClientToScreen(rt_cus);
		ClientToScreen(rt_rst);
		ClientToScreen(rt_close);
		ClientToScreen(rt_min);
		ClientToScreen(rt_report);
		//ClientToScreen(rt_convert);

		// 点击 快速采集 按钮 (鼠标按下 和松开 都在 按钮内,才判定点击成功)
		if (rt_fast.PtInRect(m_LBtnDownPos) && rt_fast.PtInRect(m_LBtnUpPos))
		{
			GetLocalDisk();
			CTOOLBOX4View::PAGE = 2;
			m_pView->SendMessage(WM_MY_PAGECHANGE);

			CReport::InitHostOpt();

			//if(CTOOLBOX4App::m_bIsLuJun)
			//	m_bIsShowConvertBtn = TRUE;

			m_pPage2->m_pPageShare->m_pgsWebFile->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsHostLog->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsAnalyze->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsFileTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsNetTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsPort->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsProcess->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsService->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsSoftWare->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsAccountSec->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsFileShare->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsUSBTrace->ShowWindow(SW_SHOW);
			//2020.12.28
			m_pPage2->m_pPageShare->m_pgsARPTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsClipboard->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsUSNTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsDNSTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsLogPolicyTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsPathInfoTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsDBLogTrace->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsNetWorkCard->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsMemory->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsHardware->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsWireless->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_pgsClipboard->ShowWindow(SW_SHOW);

			m_pPage2->m_pPageShare->m_stcWebFileStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcHostLogStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcAnalyzeStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcFileTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcNetTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcPortStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcProcessStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcServiceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcSoftWareStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcAccountSecStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcFileShareStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcUSBTraceStat->ShowWindow(SW_HIDE);

			//2020.12.28
			m_pPage2->m_pPageShare->m_stcUSNTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcARPTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcDNSTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcLogPolicyTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcPathInfoTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcDBLogTraceStat->ShowWindow(SW_HIDE);
			m_pPage2->m_pPageShare->m_stcNetWorkCardStat->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_stcMemoryStat->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_stcWirelessStat->ShowWindow(SW_SHOW);
			m_pPage2->m_pPageShare->m_stcClipboardStat->ShowWindow(SW_HIDE);
			AFX_THREADPROC MyFunc = MyThreadFunc_fast;
			CWinThread* MyThread1 = AfxBeginThread(MyFunc, this, THREAD_PRIORITY_NORMAL, 0, 0, NULL);
			//	AFX_THREADPROC MyGetFileFunc=myGetFileList;
			//	MyThreadfile = AfxBeginThread(MyGetFileFunc, this , THREAD_PRIORITY_NORMAL , 0 , 0 , NULL);
		}
		// 点击 全盘采集 按钮
		if (rt_all.PtInRect(m_LBtnDownPos) && rt_all.PtInRect(m_LBtnUpPos))
		{
			GetLocalDisk();
			CTOOLBOX4View::PAGE = 3;
			m_pView->SendMessage(WM_MY_PAGECHANGE);

			CReport::InitHostOpt();

			//if(CTOOLBOX4App::m_bIsLuJun)
			//	m_bIsShowConvertBtn = TRUE;

			m_pPage3->m_pShare->m_pgsWebFile->ShowWindow(SW_SHOW);

			m_pPage3->m_pShare->m_pgsHostLog->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsAnalyze->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsFileTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsNetTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsPort->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsProcess->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsService->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsSoftWare->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsAccountSec->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsFileShare->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsUSBTrace->ShowWindow(SW_SHOW);
			//2020.12.28
			m_pPage3->m_pShare->m_pgsUSNTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsARPTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsDNSTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsLogPolicyTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsPathInfoTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsDBLogTrace->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsNetWorkCard->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsMemory->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsHardware->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsWireless->ShowWindow(SW_SHOW);
			m_pPage3->m_pShare->m_pgsClipboard->ShowWindow(SW_SHOW);

			m_pPage3->m_pShare->m_stcWebFileStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcHostLogStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcAnalyzeStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcFileTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcNetTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcPortStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcProcessStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcServiceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcSoftWareStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcAccountSecStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcFileShareStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcUSBTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcUSNTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcDNSTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcLogPolicyTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcPathInfoTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcARPTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcDBLogTraceStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcNetWorkCardStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcMemoryStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcWirelessStat->ShowWindow(SW_HIDE);
			m_pPage3->m_pShare->m_stcClipboardStat->ShowWindow(SW_HIDE);
			AFX_THREADPROC MyFunc = MyThreadFunc_all;
			CWinThread* MyThread1 = AfxBeginThread(MyFunc, this, THREAD_PRIORITY_NORMAL, 0, 0, NULL);
			//	AFX_THREADPROC MyGetFileFunc=myGetFileList;
			//	MyThreadfile = AfxBeginThread(MyGetFileFunc, this , THREAD_PRIORITY_NORMAL , 0 , 0 , NULL);

		}
		// 点击 自定义采集 按钮
		if (rt_cus.PtInRect(m_LBtnDownPos) && rt_cus.PtInRect(m_LBtnUpPos))
		{
			GetLocalDisk();
			CTOOLBOX4View::PAGE = 4;
			m_pView->SendMessage(WM_MY_PAGECHANGE);

			// 设置起始时间为30天前
			SYSTEMTIME SysTime;
			GetLocalTime(&SysTime);	// 获取当前时间
			SYSTEMTIME SysTimeEnd = SysTime;
			time_t tTime = SystemTimeToTimet(SysTime);
			tTime -= 2592000;	// 减30天
			SysTime = TimetToSystemTime(tTime);
			m_pView->m_pPage4->m_pBeginTime->SetTime(&SysTime);
			m_pView->m_pPage4->m_pEndTime->SetTime(&SysTimeEnd);
		}
		// 点击右上角 关闭按钮 
		if (rt_close.PtInRect(m_LBtnDownPos) && rt_close.PtInRect(m_LBtnUpPos))
		{
			CDisposeResult::MyClearVector();
			CDisposeResult::MyClearVector2();
			CDisposeResult::MyClearVector3();

			//m_pView->DestroyWindow();   // 会调用析构函数
			exit(1);
		}

		// 点击 右上角最小化按钮
		if (rt_min.PtInRect(m_LBtnDownPos) && rt_min.PtInRect(m_LBtnUpPos))
		{
			m_pView->GetParent()->ShowWindow(SW_MINIMIZE);
		}


		// 点击 查看结果 按钮
		if (rt_rst.PtInRect(m_LBtnDownPos) && rt_rst.PtInRect(m_LBtnUpPos))
		{
			m_bIsShowWait = TRUE;
			Invalidate();
			UpdateWindow();
			//AFX_THREADPROC MyFunc = MyThreadFunc_BuildHtml;
			//CWinThread* MyThread1 = AfxBeginThread(MyFunc, this , THREAD_PRIORITY_NORMAL , 0 , 0 , NULL);
			//WaitForSingleObject(MyThread1->m_hThread, INFINITE);

			m_bIsShowWait = FALSE;
			Invalidate();
			UpdateWindow();

			CString str = CTOOLBOX4App::ms_strFullResultPath;
			str += _T("html\\index.html");

			// 打开html文件
			ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL);
		}

		if (rt_report.PtInRect(m_LBtnDownPos) && rt_report.PtInRect(m_LBtnUpPos))
		{
			m_bIsShowWait = TRUE;
			Invalidate();
			UpdateWindow();

			//AFX_THREADPROC MyFunc = MyThreadFunc_BuildReport;
			//CWinThread* MyThread1 = AfxBeginThread(MyFunc, this , THREAD_PRIORITY_NORMAL , 0 , 0 , NULL);
			//WaitForSingleObject(MyThread1->m_hThread, INFINITE);
			OutputDebugString(_T("F0"));
			m_bIsShowWait = FALSE;
			Invalidate();
			UpdateWindow();

			// 打开html文件
			CString str = CTOOLBOX4App::ms_strFullResultPath;
			str += _T("html\\report\\report.html");
			//OutputDebugString(_T("open html"));
			//OutputDebugString(str);
			ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL);
			OutputDebugString(_T("G0"));
		}

		// 点击 数据转换按钮
		//if(m_bIsShowConvertBtn && rt_convert.PtInRect(m_LBtnDownPos) && rt_convert.PtInRect(m_LBtnUpPos))
		//{
		//	AFX_THREADPROC MyFunc = MyThreadFunc_DataConvert;
		//	CWinThread* MyThread1 = AfxBeginThread(MyFunc, this , THREAD_PRIORITY_NORMAL , 0 , 0 , NULL);
		//}
	} while (false);
	CWnd::OnLButtonUp(nFlags, point);	
}

int nTimer3 = 0;
int nTimer4 = 0;
void CPage1::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default
	switch(nIDEvent)
	{
	case TIMER1ID:
		{
			TASKPROGRESS ofx;
			memset(&ofx, 0, sizeof(TASKPROGRESS));

			if(nTimer3 == 0)
				ofx.pszText = TEXT("开始采集.");
			else if(nTimer3 == 1)
				ofx.pszText = TEXT("开始采集..");
			else if(nTimer3 == 2)
				ofx.pszText = TEXT("开始采集...");
			else if(nTimer3 == 3)
				ofx.pszText = TEXT("开始采集");

			ofx.nProgress = 1;
			m_pPage2->SetContentText(&ofx);

			nTimer3++;
			if(nTimer3 == 4)
				nTimer3 = 0;
		}
		break;
	case TIMER61ID:
		{
			TASKPROGRESS ofx;
			memset(&ofx, 0, sizeof(TASKPROGRESS));

			if(nTimer4 == 0)
				ofx.pszText = TEXT("开始采集.");
			else if(nTimer4 == 1)
				ofx.pszText = TEXT("开始采集..");
			else if(nTimer4 == 2)
				ofx.pszText = TEXT("开始采集...");
			else if(nTimer4 == 3)
				ofx.pszText = TEXT("开始采集");
			ofx.nProgress = 1;

			m_pPage3->SetContentText(&ofx);

			nTimer4++;
			if(nTimer4 == 4)
				nTimer4 = 0;

		}
		break;
	}


	CWnd::OnTimer(nIDEvent);
}
